package com.Earth01;

import java.util.ArrayList;
import java.util.Collections;

/*
* 674. 最长连续递增序列
* */
public class Earth240711 {
    public static void main(String[] args) {
        int[] nums = {1,3,5,7};
        int res = findLengthOfLCIS(nums);
        System.out.println(res);
    }
    public static int findLengthOfLCIS(int[] nums) {
        if(nums.length == 1) return 1;
        /*
        * 快慢指针，slow指向0，fast指向1；
        * 快，慢移动，当快大于慢指针时循环；
        *            当快小于等于慢指针时停止循环，记录长度。然后快慢各加1。
        * */
        int lengthN = nums.length;
        int slow = 0;
        int fast = 1;
        int res = 0;
        int count = 1;
        while(slow < lengthN && fast < lengthN){
            if(nums[fast] <= nums[slow]){
                //说明子序列结束
                res = Math.max(count, res);//记录长度
                slow++;//更新指针
                fast++;
                count = 1;
                continue;
            }
            slow++;
            fast++;
            count++;
        }
        res = Math.max(count, res);
        return res;
    }
}
